<template>
	<div class="">
		<!--<base-header></base-header>-->
		<div class="brace-bg"></div>
		<div class="edit-event">
			<textarea v-model="content" class="edit-cont" name="" rows="" cols="" placeholder="请输入事件信息"></textarea>
			<input v-model="event_day" class="edit-data" type="text" name="" id="event_day" value="" placeholder="请输入事件时间" />
			<span @click="save" class="edit-save">保存</span>
		</div>
	</div>
</template>

<script>
	import BaseHeader from "@/components/common/BaseHeader"
	import mobiscroll from "../../../static/Mobiscroll/js/mobiscroll.custom-3.0.0-beta6.min.js"
	export default {
		name: 'BraceType',
		components: {
			BaseHeader
		},
		data() {
			return {
				uid: "",
				token: "",
				pid: '',
				content: '',
				event_day: '',
			}
		},
		mounted() {
			this.pid = this.$route.params.pid;
			this.uid = localStorage.getItem('uid');
			this.token = localStorage.getItem('token');
			var self = this;
			$('#event_day').mobiscroll().date({
				theme: 'mobiscroll',
				lang: 'zh',
				display: 'bottom',
				onClose: function(textVale, inst) { //插件效果退出时执行 inst:表示点击的状态反馈：set/cancel
					self.event_day = textVale.valueText;
				}
			});
		},
		methods: {
			//获取牙套事件详情
			getEvent() {
				var self = this;
				var data = {
					id: self.eid,
					uid: self.uid,
					token: self.token
				};
				$.post(global.domain + global.API.braces_event_info, data, function(msg) {
					self.isloading = false;
					if(msg.error == 0) {
						self.eventM = msg.data;
						self.url = msg.url;
						self.oss_url = msg.oss_url;
					} else {
						console.log(msg.error);
						if(msg.is_auth == 0) {
							localStorage.clear();
							self.$router.push({
								path: '/login'
							});
						}
					}
				}, 'json');
			},
			//保存
			save() {
				var self = this;
				var data = {
					plan_id: self.pid,
					uid: self.uid,
					token: self.token,
					content: self.content,
					event_day: self.event_day
				};
				$.post(global.domain + global.API.braces_event_save, data, function(msg) {
					if(msg.error == 0) {
						self.$router.back(-1);
					} else {
						console.log(msg.error);
						if(msg.is_auth == 0) {
							localStorage.clear();
							self.$router.push({
								path: '/login'
							});
						}
					}
				}, 'json');
			}
		}
	}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
	@import "../../style/brace.css";
	.edit-event {
		padding: 50px 20px 0;
	}
	
	.edit-cont {
		width: 100%;
		resize: none;
		height: 160px;
		padding: 20px;
		outline: none;
		background-color: rgba(255, 255, 255, 0.2);
		color: #FFFFFF;
		border: none;
	}
	
	.edit-data {
		width: 100%;
		outline: none;
		padding: 20px;
		border: none;
		background-color: rgba(255, 255, 255, 0.2);
		color: #FFFFFF;
	}
	
	.edit-save {
		width: 100%;
		display: inline-block;
		margin-top: 30px;
		color: #fff;
		text-align: center;
		background-color: transparent;
		border: 1px solid #fff;
		padding: 10px;
		font-size: 20px;
		border-radius: 40px;
	}
</style>